
#ifndef MSG_QUEUE_H
#define MSG_QUEUE_H

#include <string>

namespace c2cplatform{
namespace library{
namespace sys{


const size_t MAX_MSG_SIZE = 400000;

class CMsgQueue
{
public:
	CMsgQueue();
	~CMsgQueue();

public:
	int Initialize(
		int iKey, 
		bool bCreate);

	int PutMsg(
		long lType, 
		const char* pBuf, 
		size_t szBufLen
		);

	int GetMsg(
		long lType, 
		char* pBuf, 
		size_t& szBufLen // [IN/OUT]
		);

	int PeekMsg(
		long lType);

    int getMsgQKey() const { return m_iKey; }

	const char* GetLastErrMsg() const { return m_sLastErrMsg.c_str(); }

private:
	typedef struct tagMsgBuf
	{
        long   lType;
        char   sBuf[MAX_MSG_SIZE];
	} MsgBuf_T;

private:
	int m_iMsgQId;
	int m_iKey;
	bool m_bInit;
	MsgBuf_T m_stMsgBuf;
	std::string m_sLastErrMsg;
};

}
}
}

#endif /* MSG_QUEUE_H */
